package cn.ekgc.system.dao;

import cn.ekgc.system.pojo.dto.MenuDTO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface MenuDao {

    // 查询当前用户查询菜单
    @Select("SELECT sm.id,menu_name,menu_url,path,menu_type,parent_id,permissons  FROM " +
            " sys_menu sm LEFT JOIN sys_role_menu srm ON sm.id = srm.menu_id " +
            " LEFT JOIN sys_role sr on srm.role_id = sr.id" +
            " LEFT JOIN sys_user_role sur ON sr.id = sur.role_id" +
            " LEFT JOIN sys_user su ON sur.user_id = su.id  " +
            "WHERE su.id = #{userId} AND sm.menu_type != 3 ")
    List<MenuDTO> findMenusByUserId(Long userId);

    // 根据角色ID查询菜单
    @Select("SELECT sm.id, menu_name,menu_url,menu_type,parent_id,permissons  FROM " +
            " sys_menu sm " +
            " LEFT JOIN sys_role_menu srm ON sm.id = srm.menu_id " +
            "WHERE srm.role_id = #{roleId} ")
    List<MenuDTO> findMenusByRoleId(Long roleId);
}
